<?php
$T->loadTpl("./html/".$template."/".$qname.".html");
$T->SetTpl('cssjs','html/cssjs.inc'); 
$T->SetTpl('jsmodel','html/jsmodel.inc');     

$p=isset($_GET["p"])?$_GET["p"]:"1";
$s_name=isset($_GET["s_name"])?$_GET["s_name"]:"";
$s_where="";

if(!empty($s_name)){
    $s_where.=" and deptname like '%".$s_name."%'";
}
if($p<1)$p=1;

$pg_sql="";
$db_sql="";
if(!ckAdm()){
    $s_where.=" and mech=".$_SESSION["school"]." ";
}
$pg_sql="select count(*) from sys_department where 1=1 ".$s_where;
$db_sql="select a.*,b.name,c.sch_name from sys_department a left join sys_dict b on a.depttype=b.id left join sys_school c on a.mech=c.id where 1=1 ".$s_where." order by a.id asc limit ".(($p-1)*15).",15";

$rc=$T->db->query($pg_sql)->fetchColumn(0);
$page=getPageHtml_bt($rc,15,$p,"&t=system_dept&s_name=".$s_name);
$page=mb_convert_encoding($page, 'utf-8', 'utf-8');
$T->Set("s_name",$s_name);
$T->Set("page",$page);
$T->SetBlock("list",$db_sql);  


$T->Set("template",$template);         
$T->clearNaN();       
$T->clearNoN();
$T->display(); 